<template>
  <div class="container">
    <fast-header/>
    <div class="img-log"><img src="../assets/logo.png" alt=""></div>
    <ul class="router-link" ref="auth">
    <li>
      <span @click="toggle_login" ref="admin_blue" class="font_blue">登录</span>
    </li>
      <span class="color_gray">丨</span>
      <li>
        <span @click="toggle_register" ref="reg_blue" class="text">注册</span>
      </li>
      <li class="menu--container--bottom__slider" :style="{'left': index * 1.5 + 'rem'}"></li>
    </ul>
    <router-view></router-view>
  </div>
</template>
<script>
  import fastHeader from '@pcpt/fast-header'
  export default {
    name: "auth",
    data() {
      return {
        index: 0,
      }
    },
    methods:{
      toggle_login(){
        this.getCount();
        this.$routes.push('/root/auth/login')
      },
      toggle_register(){
        this.getCount();
        this.$routes.push('/root/auth/register')
      },
      getCount(){
        if(this.$route.name==='login'){
          this.index=0;
          this.$refs.reg_blue.className='';
          this.$refs.admin_blue.className='font_blue';
        }else{
          this.index=1;
          this.$refs.admin_blue.className='';
          this.$refs.reg_blue.className='font_blue';
        }
      }
    },
    components: {fastHeader}
    ,
    mounted(){
      this.getCount();
    },
    updated(){
      this.getCount();
    }
  }
</script>

<style scoped>
  * {
    margin: 0;
    padding: 0;
  }
  .router-link li{
     display: inline-block;
  }
  .router-link{
    position: relative;
  }
  .menu--container--bottom__slider{
    position: absolute;
    width: 8.5rem;
    bottom: 0;
    left: 0;
    height: 2px;
    border-radius: 10px;
    transition: all .4s ease;
  }
  .menu--container--bottom__slider::before{
    content: '';
    display: block;
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    margin: auto;
    width: 50%;
    max-width: .5333rem;
    height: 4px;
    border-radius: 10px;
    background: #196fe3;
  }
  .font_blue{
    color: #196fe3;
  }
  .text{
    color: #333;
  }
  .container {
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    background: #fff;
  }
  .img-log {
    margin-top: .53333rem;
    width: 100vw;
    height: 1.0666rem;
    text-align: center;
  }
  .img-log img {
    width: 1.0666rem;
    height: 1.0666rem;
  }
  .router-link {
    width: 100vw;
    text-align: center;
    color: #333;
    font-size: .42666rem;
  }
  .router-link span {
    line-height: 1rem;
    text-decoration: none;
  }
  .color_gray {
    color: #ddd;
  }
</style>
